/**
 * This file is part of 1genia trampoline
 * Copyright (C) 2007 - 2008 1genia (contact@1genia.com)
 *
 * This library is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation; version 3 of the License. 
 *
 * This library is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details. 
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; see the file COPYING.TXT.  If not,
 * write to the Free Software Foundation, Inc., 51 Franklin Street,
 * Fifth Floor, Boston, MA 02110-1301, USA. 
 **/
package com.genia.toolbox.projects.toolbox_basics_project.business.dao;

import java.util.List;

import com.genia.toolbox.persistence.criteria.Criteria;
import com.genia.toolbox.persistence.criteria.CriteriaType;
import com.genia.toolbox.persistence.criteria.PropertyField;
import com.genia.toolbox.persistence.exception.PersistenceException;
import com.genia.toolbox.projects.toolbox_basics_project.bean.model.I18nDynamicValue;
import com.genia.toolbox.projects.toolbox_basics_project.bean.model.Language;
import com.genia.toolbox.projects.toolbox_basics_project.bean.model.Namable;

/**
 * BusinessDao to do i18n search.
 */
public interface I18nSearchHelperDao
{

  /**
   * Search all {@link Namable} which {@link I18nDynamicValue} has string value
   * ilike value parameter on current language.
   * 
   * @param <T>
   *                the type of the {@link Namable}
   * @param clazz
   *                which extends {@link Namable}
   * @param value
   *                to search on
   * @return a list of {@link Namable}
   * @throws PersistenceException
   *                 if an error occurs
   */
  public <T extends Namable> List<T> searchNamable(Class<T> clazz, String value)
      throws PersistenceException;



  /**
   * Search all T which {@link I18nDynamicValue} propertyField has string value
   * ilike value parameter on current language.
   * 
   * @param <T>
   *                the type of the element having a i18n value
   * @param clazz
   *                the class of the element having a i18n value
   * @param propertyField
   *                to join on
   * @param value
   *                to search on
   * @return a list of T
   * @throws PersistenceException
   *                 if an error occurs
   */
  public <T> List<T> searchI18nDynamicString(Class<T> clazz, PropertyField<? extends I18nDynamicValue, ? extends I18nDynamicValue> propertyField, String value)
      throws PersistenceException;



  /**
   * add a restriction to the given criteria to retrieve only the value for
   * which the given property on the given criteria type for the given language
   * has the given value.
   * 
   * @param language
   *                the {@link Language} to consider
   * @param criteria
   *                the base criteria
   * @param criteriaType
   *                the {@link CriteriaType} of the element having a i18n value
   * @param propertyField
   *                to join on
   * @param value
   *                to search on
   * @throws PersistenceException
   *                 if an error occurs
   */
  public abstract void addI18nDynamicStringExactRestriction(Language language, Criteria<?> criteria, CriteriaType<?> criteriaType,
      PropertyField<? extends I18nDynamicValue, ? extends I18nDynamicValue> propertyField, String value)
      throws PersistenceException;



  /**
   * Search all T which {@link I18nDynamicValue} propertyField has string value
   * ilike value parameter on current language.
   * 
   * @param criteria
   *                the base criteria
   * @param criteriaType
   *                the {@link CriteriaType} of the element having a i18n value
   * @param propertyField
   *                to join on
   * @param value
   *                to search on
   * @throws PersistenceException
   *                 if an error occurs
   */
  public void addI18nDynamicStringRestriction(Criteria<?> criteria, CriteriaType<?> criteriaType, PropertyField<? extends I18nDynamicValue, ? extends I18nDynamicValue> propertyField, String value)
      throws PersistenceException;



  /**
   * Search all T which {@link I18nDynamicValue} propertyField has string value
   * ilike value parameter on current language, with order.
   * 
   * @param <T>
   *                the type of the element having a i18n value
   * @param clazz
   *                the class of the element having a i18n value
   * @param propertyField
   *                to join on
   * @param value
   *                to search on
   * @return a list of T
   * @throws PersistenceException
   *                 if an error occurs
   */
  public <T> List<T> searchI18nDynamicStringWithOrder(Class<T> clazz, PropertyField<? extends I18nDynamicValue, ? extends I18nDynamicValue> propertyField, String value)
      throws PersistenceException;



  /**
   * Search all T which {@link I18nDynamicValue} propertyField has string value
   * ilike value parameter on current language, with order.
   * 
   * @param criteria
   *                the base criteria
   * @param criteriaType
   *                the {@link CriteriaType} of the element having a i18n value
   * @param propertyField
   *                to join on
   * @param value
   *                to search on
   * @throws PersistenceException
   *                 if an error occurs
   */
  public void addI18nDynamicStringRestrictionWithOrder(Criteria<?> criteria, CriteriaType<?> criteriaType, PropertyField<? extends I18nDynamicValue, ? extends I18nDynamicValue> propertyField,
      String value)
      throws PersistenceException;
}
